package com.person.jc.service.security;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Record;
import com.person.jc.utils.Utils;

public class TsTemplateInfoService {
	
	public static final TsTemplateInfoService me = new TsTemplateInfoService();
	
	public List<Record> getList(Map<String,Object> map){
		String temp = "";
		List<Object> params = new ArrayList<Object>();
		StringBuffer sql = new StringBuffer("select * from ts_template_info t where t.if_valid = 1 ");
		if(Utils.isNotEmpty(temp = String.valueOf(map.get("type")))){
			sql.append(" and t.t_type = '"+ temp +"'");
		}
		if(Utils.isNotEmpty(temp = String.valueOf(map.get("id")))){
			sql.append(" and t.t_id in ("+ temp +")");
		}
		return Db.find(sql.toString(), Utils.getObjParam(params));
	}
	
	
	public Record getById(String tid){
		return Db.findById("ts_template_info", "t_id", tid);
	}
}
